%{
    This file is part of StemCellQC, a video bioinformatics software
    toolkit for analysis of phase contrast microscopy videos.
    Copyright 2013-2015 Vincent On. [vincenton001-at-gmail.com]

    StemCellQC is free software: you can redistribute it and/or 
    modify it under the terms of the GNU General Public License as 
    published by the Free Software Foundation, either version 3 of the 
    License, or (at your option) any later version.

    StemCellQC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with StemCellQC.  If not, see <http://www.gnu.org/licenses/>.
%}

function [input_value, std_value] = gen_input(Slopes_F, Feature, data_method, N_parts)

switch data_method
    case 'avg slope'
        input_value = mean(Slopes_F,2);
%         std_value = std(Slopes_F,2);

    case 'first last'
        input_value = (Feature(:,end) - Feature(:,1))/length(Feature(1,:));
        
    case 'normal'
        input_value = mean(Feature,2); % use for regular feature and not slope of feature
%         std_value = std(Feature,2);
        
    case 'hist slope'
        
        for i = 1 : length(Slopes_F(:,1))
            h = histc(Slopes_F(i,:),0:0.01:1);
            [~,ind] = max(h);
            input_value(i) = 0.01*ind;
        end
        
    case 'voting'
        n_frame = length(Feature(1,:));
        interval = n_frame/N_parts;
        input_value = zeros(length(Feature(:,1)),N_parts);
        for j = 1: length(Feature(:,1))
            for i = 1:N_parts
                temp = Feature((i-1)*interval+1:i*interval);
                
                %least squares slope
                [p, ~] = polyfit(1:interval,temp,1);
                
                input_value(j,i) = p(1);
            end
        end
        
        
end


std_value = NaN;